/* GUI CONVERTED from rcsoisk.p (converter v1.75) Tue Apr 10 12:05:51 2001 */
/* rcsoisk.p - Shipper Confirmation Process Kit Parent & Its Components       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5.1.6 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 8.6    LAST MODIFIED: 10/18/96   BY: *K003* Forrest Mori         */
/* REVISION: 8.6    LAST MODIFIED: 11/04/97   BY: *K15N* Jim Williams         */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane            */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan           */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan           */
/* REVISION: 8.6E   LAST MODIFIED: 08/12/99   BY: *J3KJ* Bengt Johansson      */
/* REVISION: 8.6E   LAST MODIFIED: 01/11/00   BY: *J3N7* Reetu Kapoor         */
/* REVISION: 9.1    LAST MODIFIED: 07/25/00   BY: *N0GD* Ganga Subramanian    */
/* $Revision: 1.5.1.6 $   BY: Jean Miller       DATE: 03/22/01  ECO: *P008*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rcsoisk_p_2 "Effective"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/* INPUT VARIABLES */
define input parameter abs_recno as recid no-undo.
define input parameter confirm_mode like mfc_logical no-undo.
define input parameter sod-qty-chg  like sod_qty_chg no-undo.

/* SHARED VARIABLES */
define new shared variable wo_recno as recid.
define new shared variable wolot like tr_lot.
define     shared variable qty_iss_rcv like tr_qty_loc.
define     shared variable accum_wip like tr_gl_amt.
define     shared variable eff_date like glt_effdate label {&rcsoisk_p_2}.
define     shared variable sod_recno as recid.
define     shared variable ship_dt like so_ship_date.

/* ADDED NEXT 4 NEW SHARED VARIABLES FOR USE IN soise03.p CALLED */
/* FROM rcosisk3.p WHICH IS ALSO USED IN SO SHIPMENTS (sosois.p) */
/* WHICH USES THESE VARIABLES FOR MULTI-DB CAPABILITIES          */
define new shared variable change_db like mfc_logical.
define new shared variable ship_db like dc_name.
define new shared variable so_db like dc_name.
define new shared variable undo-select like mfc_logical no-undo.

/* VARIABLES */
define variable srline like sr_line no-undo.
define variable abs_db as character no-undo.
define variable err_flag as integer no-undo.
define variable msg1 as character format "x(24)" no-undo.

/* DEFINE BUFFERS */
define buffer abs_comp for abs_mstr.
define buffer abs_temp for abs_mstr.

/* TEMP TABLES */

{rcwabsdf.i}

msg1 ="'" +  getTermLabel("FOR_SALES_ORDERS",24) + "'".

find sod_det where recid(sod_det) = sod_recno no-lock no-error.
find abs_mstr where recid(abs_mstr) = abs_recno no-lock no-error.

find si_mstr where si_site = sod_site no-lock.
assign
   abs_db = global_db
   so_db = abs_db
   ship_db = si_db
   change_db = ship_db <> global_db.

/* SWITCH TO INVENTORY DATABASE */

if si_db <> abs_db then do:
   {gprun.i ""gpalias3.p"" "(input si_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if err_flag <> 0 and err_flag <> 9 then do:
      /* DATABASE # IS NOT CONNECTED */
      {pxmsg.i &MSGNUM = 2510 &ERRORLEVEL = 4 &MSGARG1 = msg1}
      return.
   end.
end. /* if si_db <> abs_db then do: */

/* CLEAR sr_wkfl */
{gprun.i ""rcsoisk1.p"" "(input abs_line)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/* SWITCH BACK TO SALES ORDER DATABASE */
if si_db <> abs_db then do:
   {gprun.i ""gpalias3.p"" "(input abs_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if err_flag <> 0 and err_flag <> 9 then do:
      /* DATABASE # IS NOT CONNECTED */
      {pxmsg.i &MSGNUM = 2510 &ERRORLEVEL = 4 &MSGARG1 = msg1}
      return.
   end.
end. /* if si_db <> abs_db then do: */

/* TO CREATE ISS-FAS TRANSACTIONS FOR KIT COMPONENT ITEMS */
/* DURING UNCONFIRMATION OF SHIPPERS                      */
for each work_abs_mstr no-lock
   where work_abs_mstr.abs_order  = abs_mstr.abs_order  and
         work_abs_mstr.abs_line   = abs_mstr.abs_line   and
         work_abs_mstr.abs_item   = abs_mstr.abs_item,
    each abs_comp no-lock
   where abs_comp.abs_shipfrom    = work_abs_mstr.abs_shipfrom and
         abs_comp.abs_par_id      = work_abs_mstr.abs_id and
         abs_comp.abs_id begins "I"
break by abs_comp.abs_item
      by abs_comp.abs_site
      by abs_comp.abs_loc
      by abs_comp.abs_lotser
      by abs_comp.abs_ref:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* This accumulates the quantity for the components */
   accumulate abs_comp.abs_qty (total by abs_comp.abs_ref).

   if last-of(abs_comp.abs_ref) then do:

      srline = abs_comp.abs_line + "ISS" + abs_comp.abs_item.

      if si_db <> abs_db then do:
         {gprun.i ""gpalias3.p"" "(input si_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         if err_flag <> 0 and err_flag <> 9 then do:
            /* DATABASE # IS NOT CONNECTED */
            {pxmsg.i &MSGNUM = 2510 &ERRORLEVEL = 4 &MSGARG1 = msg1}
            return.
         end.
      end. /* if si_db <> abs_db then do: */

      /* CREATE sr_wkfl FOR COMPONENTS */
      {gprun.i ""rcsoisk2.p""
         "(input confirm_mode,
           input srline,
           input abs_comp.abs_site,
           input abs_comp.abs_loc,
           input abs_comp.abs_lotser,
           input abs_comp.abs_ref,
           input accum total by abs_comp.abs_ref abs_comp.abs_qty)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if si_db <> abs_db then do:
         {gprun.i ""gpalias3.p"" "(input abs_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         if err_flag <> 0 and err_flag <> 9 then do:
            /* DATABASE # IS NOT CONNECTED */
            {pxmsg.i &MSGNUM=2510 &ERRORLEVEL=4 &MSGARG1=msg1}
            return.
         end.
      end. /* if si_db <> abs_db then do: */

   end. /* if last-of(abs_comp.abs_ref) then do: */

   /* UPDATE abs_mstr FOR COMPONENTS */
   find abs_temp where
        abs_temp.abs_shipfrom = abs_comp.abs_shipfrom and
        abs_temp.abs_id = abs_comp.abs_id
   exclusive-lock no-error.

   /* CONFIRM */
   if available abs_temp and confirm_mode then
   assign
      abs_temp.abs_ship_qty = abs_temp.abs_qty
      abs_temp.abs_shp_date = ship_dt.

   /* UNCONFIRM */
   else
   if available abs_temp then
   assign
      abs_temp.abs_ship_qty = 0
      abs_temp.abs_shp_date = ?.

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for each work_abs_mstr, abs_comp .... break by ...*/

/* SWITCH TO INVENTORY DATABASE */
if si_db <> abs_db then do:
   {gprun.i ""gpalias3.p"" "(input si_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if err_flag <> 0 and err_flag <> 9 then do:
      /* DATABASE # IS NOT CONNECTED */
      {pxmsg.i &MSGNUM=2510 &ERRORLEVEL=4 &MSGARG1=msg1}
      return.
   end.
end. /* if si_db <> abs_db then do: */

/* CREATE sr_wkfl FOR THE KIT PARENT                               */
/* soise03.p - ISSUE COMPONENTS (ISS-FAS)                          */
/* soise04.p - PROCESS PARENT RECEIPT (RCT-FAS) & CREATE VARIANCES */
/* CLEAR sr_wkfl                                                   */
{gprun.i ""rcsoisk3.p""
   "(input confirm_mode,
     input sod_nbr,
     input sod_line,
     input abs_mstr.abs_line,
     input abs_mstr.abs_site,
     input abs_mstr.abs_loc,
     input abs_mstr.abs_lotser,
     input abs_mstr.abs_ref,
     input sod-qty-chg)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/* SWITCH BACK TO SALES ORDER DATABASE */
if si_db <> abs_db then do:
   {gprun.i ""gpalias3.p"" "(input abs_db, output err_flag)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if err_flag <> 0 and err_flag <> 9 then do:
      /* DATABASE # IS NOT CONNECTED */
      {pxmsg.i &MSGNUM=2510 &ERRORLEVEL=4 &MSGARG1=msg1}
      return.
   end.
end. /* if si_db <> abs_db then do: */
